/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package za.co.pas.business.view.model.list;

import java.util.LinkedList;
import java.util.List;
import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
import za.co.pas.business.data.UserLoginDetails;

/**
 *
 * @author alabuschagne
 */
public class UserListModel implements ListModel
{
    private List<UserLoginDetails> users = new LinkedList<UserLoginDetails>();
    @Override
    public int getSize()
    {
        if(users == null)
        {
            return 0;
        }
        return users.size();
    }

    @Override
    public Object getElementAt(int index)
    {
        if((users == null) || (users.isEmpty()))
        {
            return null;
        }
        return users.get(index);
    }

    @Override
    public void addListDataListener(ListDataListener l)
    {
        
    }

    @Override
    public void removeListDataListener(ListDataListener l)
    {
        
    }

    /**
     * @return the users
     */
    public List<UserLoginDetails> getUsers()
    {
        return users;
    }

    /**
     * @param users the users to set
     */
    public void setUsers(List<UserLoginDetails> users)
    {
        this.users = users;
    }

    public void addUser(UserLoginDetails user)
    {
        if(this.users == null)
        {
            users = new LinkedList<UserLoginDetails>();
        }
        users.add(user);
    }

}
